<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get log count by level, log_path and key_word</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="seaslog.alert.html">« SeasLog::alert</a></li>
      <li style="float: right;"><a href="seaslog.analyzerdetail.html">SeasLog::analyzerDetail »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.seaslog.html">SeasLog</a></li>
    <li>Get log count by level, log_path and key_word</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="seaslog.analyzercount" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SeasLog::analyzerCount</h1>
  <p class="verinfo">(PECL seaslog &gt;=1.1.6)</p><p class="refpurpose"><span class="refname">SeasLog::analyzerCount</span> &mdash; <span class="dc-title">Get log count by level, log_path and key_word</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-seaslog.analyzercount-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>SeasLog::analyzerCount</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$level</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$log_path</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$key_word</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
    `SeasLog` get count value of `grep -ai &#039;{level}&#039; | grep -aic &#039;{key_word}&#039;` 
    use system pipe and return to PHP (array or int).
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-seaslog.analyzercount-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">level</code></dt>

    <dd>

     <p class="para">
      String. The log information level.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">log_path</code></dt>

    <dd>

     <p class="para">
      String. The log information path.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">key_word</code></dt>

    <dd>

     <p class="para">
      String. The search key word for log information.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-seaslog.analyzercount-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   If `level` is SEASLOG_ALL or Empty, return all levels count as `array`.
   If `level` is SEASLOG_INFO or the other level, return count as `int`.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-seaslog.analyzercount-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3516">
   <p><strong>示例 #1 <span class="function"><strong>SeasLog::analyzerCount()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$countResult1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">SeasLog</span><span style="color: #007700">::</span><span style="color: #0000BB">analyzerCount</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//with&nbsp;`level`<br /></span><span style="color: #0000BB">$countResult2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">SeasLog</span><span style="color: #007700">::</span><span style="color: #0000BB">analyzerCount</span><span style="color: #007700">(</span><span style="color: #0000BB">SEASLOG_DEBUG</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//with&nbsp;`level`&nbsp;and&nbsp;`log_path`<br /></span><span style="color: #0000BB">$countResult3&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">SeasLog</span><span style="color: #007700">::</span><span style="color: #0000BB">analyzerCount</span><span style="color: #007700">(</span><span style="color: #0000BB">SEASLOG_ERROR</span><span style="color: #007700">,</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Ymd'</span><span style="color: #007700">,</span><span style="color: #0000BB">time</span><span style="color: #007700">()));<br /><br /></span><span style="color: #FF8000">//with&nbsp;`level`&nbsp;and&nbsp;`key_word`<br /></span><span style="color: #0000BB">$countResult4&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">SeasLog</span><span style="color: #007700">::</span><span style="color: #0000BB">analyzerCount</span><span style="color: #007700">(</span><span style="color: #0000BB">SEASLOG_DEBUG</span><span style="color: #007700">,</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,</span><span style="color: #DD0000">'accessToken'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$countResult1</span><span style="color: #007700">,</span><span style="color: #0000BB">$countResult2</span><span style="color: #007700">,</span><span style="color: #0000BB">$countResult3</span><span style="color: #007700">,</span><span style="color: #0000BB">$countResult4</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(8) {
  [&quot;DEBUG&quot;]=&gt;
  int(180)
  [&quot;INFO&quot;]=&gt;
  int(214)
  [&quot;NOTICE&quot;]=&gt;
  int(0)
  [&quot;WARNING&quot;]=&gt;
  int(0)
  [&quot;ERROR&quot;]=&gt;
  int(228)
  [&quot;CRITICAL&quot;]=&gt;
  int(244)
  [&quot;ALERT&quot;]=&gt;
  int(1)
  [&quot;EMERGENCY&quot;]=&gt;
  int(0)
}

int(180)

int(228)

int(29)
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-seaslog.analyzercount-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="seaslog.analyzerdetail.html" class="methodname" rel="rdfs-seeAlso">SeasLog::analyzerDetail()</a> - Get log detail by level, log_path, key_word, start, limit, order</span></li>
  </ul>
 </div>


</div></div></div></body></html>